#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <arpa/inet.h>

typedef unsigned short  U16;
typedef unsigned char   U8;
typedef unsigned int    U32;
typedef unsigned long long    U64;

typedef struct
{
    U16 wanindex; /* current support: 1 */
    U8 connect_type;
    U16 mtu;
    U16 nat_mode; /* do nat when !0 */
    U8 mac[6];
    char user[64];        /*  valid when pppoe */
    char server_name[64]; /* valid when pppoe */
    char ac_name[64];     /* valid when pppoe拨号连接的名称 */
    struct in_addr ip;
    struct in_addr mask;
    struct in_addr gw;
    struct in_addr master_dns;
    struct in_addr slave_dns;
    U16 conn_num;      // 当前连接数
    U8 connect_status; // 物理口连接状态 0-未链接，1-链接
} __attribute__((packed)) wan_cfg;

int main(void)
{
    wan_cfg pwan_cfg;

    wan_cfg *debug = &pwan_cfg;

    char *getmac = "dc:4a:3e:8f:a0:d1";

    sscanf(getmac, "%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX", &debug->mac[0], &debug->mac[1], &debug->mac[2], &debug->mac[3], &debug->mac[4], &debug->mac[5]);

    printf("mac = %02x:%02x:%02x:%02x:%02x:%02x \n", pwan_cfg.mac[0], pwan_cfg.mac[1], pwan_cfg.mac[2], pwan_cfg.mac[3], pwan_cfg.mac[4], pwan_cfg.mac[5]);

    return 0;
}
